﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FoundationLib.Data.NHibernate.Configuration
{
	/// <summary>
	/// This class represents the mapping information section for NHibernate.
	/// </summary>
	public class NHibernateConfigSection : ConfigurationSection
	{
		/// <summary>
		/// Creates a new <see cref="NHibernateConfigSection"/>.
		/// </summary>
		public NHibernateConfigSection()
			: base()
		{
		}

		/// <summary>
		/// Gets the configuration file settings.
		/// </summary>
		[ConfigurationProperty("file", IsRequired = true)]
		public NHibernateConfigElement File
		{
			get
			{
				return (this["file"] as NHibernateConfigElement);
			}
		}

		/// <summary>
		/// Loads and returns the NHibernate mapping configuration section from the config file.
		/// </summary>
		/// <returns>The <see cref="NHibernateConfigSection"/> instance</returns>
		public static NHibernateConfigSection FromConfiguration()
		{
			NHibernateConfigSection section = ConfigurationManager.GetSection("nhibernateConfiguration")
				as NHibernateConfigSection;

			return section;
		}
	}
}
